<script setup lang="ts">
import type { Template } from '@/types/template'
import { ref } from 'vue'
import { getTemplateSearchApi } from '@/services/template'

// 获取线路数据
const key = ref<string>('')
const list = ref<Template[]>([])
const onSearch = async () => {
  const res = await getTemplateSearchApi(key.value)
  list.value = res.data
}
</script>

<template>
  <view class="search-bar">
    <view class="search-box">
      <input
        class="input"
        type="text"
        placeholder="可填写目的地 关键字 景点"
        v-model="key"
        placeholder-class="input-placeholder"
      />
      <view class="search-button" @click="onSearch()">搜索</view>
    </view>
  </view>
  <scroll-view class="scroll-view" scroll-y>
    <view class="list-warp">
      <HxTemplate :list="list" />
    </view>
  </scroll-view>
</template>

<style lang="scss" scoped>
/* #ifdef APP-PLUS */
#app,
/* #endif */
page {
  background-color: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  .scroll-view {
    flex: 1;
  }
}
.search-bar {
  padding: 16px 16px 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  .search-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background-color: #80e2d0;
    padding: 0 0 0 16px;
    height: 40px;
    border-radius: 24px;
    font-size: $fs-xs;
    .search-button {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 80px;
      height: 40px;
      border-radius: 24px;
      background-color: #00c19e;
      color: #fff;
      font-size: $fs-lg;
      font-weight: bold;
    }
  }
  .input {
    font-size: $fs-lg;
    width: 470rpx;
  }
  .input-placeholder {
    color: #fff;
  }
}
.list-warp {
  padding: 0 32rpx 48rpx;
  color: #333;
  margin-top: 32rpx;
}
</style>
